我的哔哩传参[官].js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /**
  2. * 已知问题:
  3. * [推荐]页面:'雷电模拟器'播放部份影片会出错,'播放器'改成'ijk' & '解码方式'改成'软解',即可正常播放
  4. * 影视TV 超連結跳轉支持
  5. * 影视TV 弹幕支持
  6. * https://t.me/fongmi_offical/
  7. * https://github.com/FongMi/Release/tree/main/apk
  8. * 皮皮虾DMBox 弹幕支持
  9. * 设置 > 窗口预览 > 开启
  10. * https://t.me/pipixiawerun
  11. * vod_area:'bilidanmu'
  12. * Cookie设置
  13. * Cookie获取方法 https://ghproxy.net/https://raw.githubusercontent.com/UndCover/PyramidStore/main/list.md
  14. * Cookie设置方法1: DR-PY 后台管理界面
  15. * CMS后台管理 > 设置中心 > 环境变量 > {"bili_cookie":"XXXXXXX","vmid":"XXXXXX"} > 保存
  16. * Cookie设置方法2: 手动替换Cookie
  17. * 底下代码 headers的
  18. * "Cookie":"$bili_cookie"
  19. * 手动替换为
  20. * "Cookie":"将获取的Cookie黏贴在这"
  21. * 客户端长期Cookie设置教程:
  22. * 抓包哔哩手机端搜索access_key,取任意链接里的access_key和appkey在drpy环境变量中增加同名的环境变量即可
  23. * 此时哔哩.js这个解析可用于此源的解析线路用
  24. * 传参 ?type=url&params=../json/小学教育.json
  25. */
  26. var rule = {
  27. title:'我的哔哩-小学教育[官]',
  28. host:'https://api.bilibili.com',
  29. homeUrl:'/x/web-interface/ranking/v2?rid=0&type=origin',
  30. url:'/x/web-interface/search/type?search_type=video&keyword=fyclass&page=fypage',
  31. class_parse:`js:
  32. log('rule.params:'+rule.params);
  33. let html=request(rule.params);
  34. let json = dealJson(html);
  35. input=json.classes;
  36. homeObj.filter = json.filter;
  37. // log(input);
  38. `,
  39. filterable: 1,
  40. detailUrl:'/x/web-interface/view/detail?aid=fyid',
  41. searchUrl:'/x/web-interface/search/type?search_type=video&keyword=**&page=fypage',
  42. searchable:2,
  43. quickSearch:0,
  44. headers:{
  45. "User-Agent":"PC_UA",
  46. "Referer": "https://www.bilibili.com",
  47. "Cookie": "buvid3=666"
  48. },
  49. timeout:5000,
  50. limit:8,
  51. play_parse:true,
  52. double:false,
  53. lazy:`js:
  54. let ids = input.split('_');
  55. let dan = 'https://api.bilibili.com/x/v1/dm/list.so?oid=' + ids[1];
  56. let result = {};
  57. let iurl = 'https://api.bilibili.com:443/x/player/playurl?avid=' + ids[0] + '&cid=' + ids[1] + '&qn=116';
  58. let html = request(iurl);
  59. let jRoot = JSON.parse(html);
  60. let jo = jRoot.data;
  61. let ja = jo.durl;
  62. let maxSize = -1;
  63. let position = -1;
  64. ja.forEach(function(tmpJo, i) {
  65. if (maxSize < Number(tmpJo.size)) {
  66. maxSize = Number(tmpJo.size);
  67. position = i
  68. }
  69. });
  70. let purl = '';
  71. if (ja.length > 0) {
  72. if (position === -1) {
  73. position = 0
  74. }
  75. purl = ja[position].url
  76. }
  77. result.parse = 0;
  78. result.playUrl = '';
  79. result.url = unescape(purl);
  80. result.header = {
  81. 'Referer': 'https://live.bilibili.com',
  82. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  83. };
  84. if (/\\.flv/.test(purl)) {
  85. result.contentType = 'video/x-flv';
  86. } else {
  87. result.contentType = '';
  88. }
  89. result.danmaku = dan;
  90. input = result
  91. `,
  92. 推荐:`js:
  93. function stripHtmlTag(src) {
  94. return src.replace(/<\\/?[^>]+(>|$)/g, '').replace(/&.{1,5};/g, '').replace(/\\s{2,}/g, ' ');
  95. }
  96. function turnDHM(duration) {
  97. let min = '';
  98. let sec = '';
  99. try {
  100. min = duration.split(':')[0];
  101. sec = duration.split(':')[1];
  102. } catch (e) {
  103. min = Math.floor(duration / 60);
  104. sec = duration % 60;
  105. }
  106. if (isNaN(parseInt(duration))) {
  107. return '无效输入';
  108. }
  109. if (min == 0) {
  110. return sec + '秒'
  111. } else if (0 < min && min < 60) {
  112. return min + '分'
  113. } else if (60 <= min && min < 1440) {
  114. if (min % 60 == 0) {
  115. let h = min / 60;
  116. return h + '小时'
  117. } else {
  118. let h = min / 60;
  119. h = (h + '').split('.')[0];
  120. let m = min % 60;
  121. return h + '小时' + m + '分';
  122. }
  123. } else if (min >= 1440) {
  124. let d = min / 60 / 24;
  125. d = (d + '').split('.')[0];
  126. let h = min / 60 % 24;
  127. h = (h + '').split('.')[0];
  128. let m = min % 60;
  129. let dhm = '';
  130. if (d > 0) {
  131. dhm = d + '天'
  132. }
  133. if (h >= 1) {
  134. dhm = dhm + h + '小时'
  135. }
  136. if (m > 0) {
  137. dhm = dhm + m + '分'
  138. }
  139. return dhm
  140. }
  141. return null
  142. }
  143. function ConvertNum(num) {
  144. let _ws = Math.pow(10, 1);
  145. let _b = 1e4;
  146. if (num < _b) {
  147. return num.toString();
  148. }
  149. let _r = '';
  150. let _strArg = ['', '万', '亿', '万亿'];
  151. let _i = Math.floor(Math.log(num) / Math.log(_b));
  152. if (_i > 3) {
  153. _i = 3;
  154. }
  155. _r = Math.floor(num / Math.pow(_b, _i) * _ws) / _ws + _strArg[_i];
  156. return _r;
  157. }
  158. let html = request(input);
  159. let vodList = JSON.parse(html).data.list;
  160. let videos = [];
  161. vodList.forEach(function(vod) {
  162. let aid = vod.aid;
  163. let title = stripHtmlTag(vod.title);
  164. let img = vod.pic;
  165. if (img.startsWith('//')) {
  166. img = 'https:' + img;
  167. }
  168. let remark = turnDHM(vod.duration) + ' ▶' + ConvertNum(vod.stat.view) + ' 🆙' + vod.owner.name;
  169. videos.push({
  170. vod_id: aid,
  171. vod_name: title,
  172. vod_pic: img,
  173. vod_remarks: remark
  174. })
  175. });
  176. VODS = videos
  177. `,
  178. 一级:`js:
  179. if (cateObj.tid.endsWith('_clicklink')) {
  180. cateObj.tid = cateObj.tid.split('_')[0];
  181. input = HOST + '/x/web-interface/search/type?search_type=video&keyword=' + cateObj.tid + '&page=' + MY_PAGE;
  182. }
  183. function stripHtmlTag(src) {
  184. return src.replace(/<\\/?[^>]+(>|$)/g, '').replace(/&.{1,5};/g, '').replace(/\\s{2,}/g, ' ');
  185. }
  186. function turnDHM(duration) {
  187. let min = '';
  188. let sec = '';
  189. try {
  190. min = duration.split(':')[0];
  191. sec = duration.split(':')[1];
  192. } catch (e) {
  193. min = Math.floor(duration / 60);
  194. sec = duration % 60;
  195. }
  196. if (isNaN(parseInt(duration))) {
  197. return '无效输入';
  198. }
  199. if (min == 0) {
  200. return sec + '秒'
  201. } else if (0 < min && min < 60) {
  202. return min + '分'
  203. } else if (60 <= min && min < 1440) {
  204. if (min % 60 == 0) {
  205. let h = min / 60;
  206. return h + '小时'
  207. } else {
  208. let h = min / 60;
  209. h = (h + '').split('.')[0];
  210. let m = min % 60;
  211. return h + '小时' + m + '分';
  212. }
  213. } else if (min >= 1440) {
  214. let d = min / 60 / 24;
  215. d = (d + '').split('.')[0];
  216. let h = min / 60 % 24;
  217. h = (h + '').split('.')[0];
  218. let m = min % 60;
  219. let dhm = '';
  220. if (d > 0) {
  221. dhm = d + '天'
  222. }
  223. if (h >= 1) {
  224. dhm = dhm + h + '小时'
  225. }
  226. if (m > 0) {
  227. dhm = dhm + m + '分'
  228. }
  229. return dhm
  230. }
  231. return null
  232. }
  233. function ConvertNum(num) {
  234. let _ws = Math.pow(10, 1);
  235. let _b = 1e4;
  236. if (num < _b) {
  237. return num.toString();
  238. }
  239. let _r = '';
  240. let _strArg = ['', '万', '亿', '万亿'];
  241. let _i = Math.floor(Math.log(num) / Math.log(_b));
  242. if (_i > 3) {
  243. _i = 3;
  244. }
  245. _r = Math.floor(num / Math.pow(_b, _i) * _ws) / _ws + _strArg[_i];
  246. return _r;
  247. }
  248. let data = [];
  249. let vodList = [];
  250. if (MY_CATE === '推荐') {
  251. input = HOST + '/x/web-interface/index/top/rcmd?ps=14&fresh_idx=' + MY_PAGE + '&fresh_idx_1h=' + MY_PAGE;
  252. data = JSON.parse(request(input)).data;
  253. vodList = data.item;
  254. } else if (MY_CATE === '历史记录') {
  255. input = HOST + '/x/v2/history?pn=' + MY_PAGE;
  256. data = JSON.parse(request(input)).data;
  257. vodList = data;
  258. } else {
  259. data = JSON.parse(request(input)).data;
  260. vodList = data.result;
  261. }
  262. let videos = [];
  263. vodList.forEach(function(vod) {
  264. let aid = vod.aid?vod.aid:vod.id;
  265. let title = stripHtmlTag(vod.title);
  266. let img = vod.pic;
  267. if (img.startsWith('//')) {
  268. img = 'https:' + img;
  269. }
  270. let play = '';
  271. let danmaku = '';
  272. if (MY_CATE === '推荐') {
  273. play = ConvertNum(vod.stat.view);
  274. danmaku = vod.stat.danmaku;
  275. } else if (MY_CATE === '历史记录') {
  276. play = ConvertNum(vod.stat.view);
  277. danmaku = vod.stat.danmaku;
  278. } else {
  279. play = ConvertNum(vod.play);
  280. danmaku = vod.video_review;
  281. }
  282. let remark = turnDHM(vod.duration) + ' ▶' + play + ' 💬' + danmaku;
  283. videos.push({
  284. vod_id: aid,
  285. vod_name: title,
  286. vod_pic: img,
  287. vod_remarks: remark
  288. })
  289. });
  290. VODS = videos
  291. `,
  292. 二级:`js:
  293. function stripHtmlTag(src) {
  294. return src.replace(/<\\/?[^>]+(>|$)/g, '').replace(/&.{1,5};/g, '').replace(/\\s{2,}/g, ' ');
  295. }
  296. let html = request(input);
  297. let jo = JSON.parse(html).data.View;
  298. // 历史记录
  299. let cookies = rule_fetch_params.headers.Cookie.split(';');
  300. let bili_jct = '';
  301. cookies.forEach(cookie => {
  302. if (cookie.includes('bili_jct')) {
  303. bili_jct = cookie.split('=')[1];
  304. }
  305. });
  306. if (bili_jct !== '') {
  307. let historyReport = 'https://api.bilibili.com/x/v2/history/report';
  308. let dataPost = {
  309. aid: jo.aid,
  310. cid: jo.cid,
  311. csrf: bili_jct,
  312. };
  313. post(historyReport, dataPost, 'form');
  314. }
  315. let stat = jo.stat;
  316. let up_info = JSON.parse(html).data.Card;
  317. let relation = up_info.following ? '已关注' : '未关注';
  318. let aid = jo.aid;
  319. let title = stripHtmlTag(jo.title);
  320. let pic = jo.pic;
  321. let desc = jo.desc;
  322. let date = new Date(jo.pubdate * 1000);
  323. let yy = date.getFullYear().toString();
  324. let mm = date.getMonth()+1;
  325. mm = mm < 10 ? ('0' + mm) : mm;
  326. let dd = date.getDate();
  327. dd = dd < 10 ? ('0' + dd) : dd;
  328. let up_name = jo.owner.name;
  329. let typeName = jo.tname;
  330. // let remark = jo.duration;
  331. let vod = {
  332. vod_id: aid,
  333. vod_name: title,
  334. vod_pic: pic,
  335. type_name: typeName,
  336. vod_year: yy+mm+dd,
  337. vod_area: 'bilidanmu',
  338. // vod_remarks: remark,
  339. vod_tags: 'mv',
  340. // vod_director: '🆙 ' + up_name + ' 👥 ' + up_info.follower + ' ' + relation,
  341. vod_director: '🆙 ' + '[a=cr:' + JSON.stringify({'id':up_name + '_clicklink','name':up_name}) + '/]' + up_name + '[/a]' + ' 👥 ' + up_info.follower + ' ' + relation,
  342. vod_actor: '▶' + stat.view + ' ' + '💬' + stat.danmaku + ' ' + '👍' + stat.like + ' ' + '💰' + stat.coin + ' ' + '⭐' + stat.favorite,
  343. vod_content: desc
  344. };
  345. let ja = jo.pages;
  346. let treeMap = {};
  347. let playurls = [];
  348. ja.forEach(function(tmpJo) {
  349. let cid = tmpJo.cid;
  350. let part = tmpJo.part.replaceAll('#', '﹟').replaceAll('$', '﹩');
  351. playurls.push(
  352. part + '$' + aid + '_' + cid
  353. )
  354. });
  355. treeMap['B站'] = playurls.join('#');
  356. let relatedData = JSON.parse(html).data.Related;
  357. playurls = [];
  358. relatedData.forEach(function(rd) {
  359. let ccid = rd.cid;
  360. let title = rd.title.replaceAll('#', '﹟').replaceAll('$', '﹩');
  361. let aaid = rd.aid;
  362. playurls.push(
  363. title + '$' + aaid + '_' + ccid
  364. )
  365. });
  366. treeMap['相关推荐'] = playurls.join('#');
  367. vod.vod_play_from = Object.keys(treeMap).join("$$$");
  368. vod.vod_play_url = Object.values(treeMap).join("$$$");
  369. VOD = vod;
  370. `,
  371. 搜索:`js:
  372. let html = request(input);
  373. function stripHtmlTag(src) {
  374. return src.replace(/<\\/?[^>]+(>|$)/g, '').replace(/&.{1,5};/g, '').replace(/\\s{2,}/g, ' ');
  375. }
  376. function turnDHM(duration) {
  377. let min = '';
  378. let sec = '';
  379. try {
  380. min = duration.split(':')[0];
  381. sec = duration.split(':')[1];
  382. } catch (e) {
  383. min = Math.floor(duration / 60);
  384. sec = duration % 60;
  385. }
  386. if (isNaN(parseInt(duration))) {
  387. return '无效输入';
  388. }
  389. if (min == 0) {
  390. return sec + '秒'
  391. } else if (0 < min && min < 60) {
  392. return min + '分'
  393. } else if (60 <= min && min < 1440) {
  394. if (min % 60 == 0) {
  395. let h = min / 60;
  396. return h + '小时'
  397. } else {
  398. let h = min / 60;
  399. h = (h + '').split('.')[0];
  400. let m = min % 60;
  401. return h + '小时' + m + '分';
  402. }
  403. } else if (min >= 1440) {
  404. let d = min / 60 / 24;
  405. d = (d + '').split('.')[0];
  406. let h = min / 60 % 24;
  407. h = (h + '').split('.')[0];
  408. let m = min % 60;
  409. let dhm = '';
  410. if (d > 0) {
  411. dhm = d + '天'
  412. }
  413. if (h >= 1) {
  414. dhm = dhm + h + '小时'
  415. }
  416. if (m > 0) {
  417. dhm = dhm + m + '分'
  418. }
  419. return dhm
  420. }
  421. return null
  422. }
  423. let videos = [];
  424. let vodList = JSON.parse(html).data.result;
  425. vodList.forEach(function(vod) {
  426. let aid = vod.aid;
  427. let title = stripHtmlTag(vod.title);
  428. let img = vod.pic;
  429. if (img.startsWith('//')) {
  430. img = 'https:' + img;
  431. }
  432. let remark = turnDHM(vod.duration);
  433. videos.push({
  434. vod_id: aid,
  435. vod_name: title,
  436. vod_pic: img,
  437. vod_remarks: remark
  438. })
  439. });
  440. VODS = videos
  441. `,
  442. }